package com.ysz.component.conf;

import com.ysz.component.constant.MyBatisConst;
import com.ysz.component.log.MyBatisLogInterceptor;
import com.ysz.component.page.MyBatisPageInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @ClassName MyBatisLogInterceptorConfig
 * @Description 配置mybatis的日志拦截
 * @Data 18:05
 * @Version 1.0
 * @Author ysz
 */
@Configuration
public class MyBatisLogInterceptorConfig {


    @Bean
    public Interceptor myBatisLogInterceptor() {
        Properties properties = new Properties();
        properties.setProperty(MyBatisConst.sql_trace_watch.getKey(), MyBatisConst.sql_trace_watch_enable.getValue());
        MyBatisLogInterceptor myBatisInterceptor = new MyBatisLogInterceptor();
        myBatisInterceptor.setProperties(properties);
        return myBatisInterceptor;
    }
}
